package com.briup.jz.web.controller;

import com.briup.jz.bean.BaseUser;
import com.briup.jz.bean.CertificationApply;
import com.briup.jz.service.IBaseUserService;

import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(description="用户相关接口")
@Validated
@RestController
@RequestMapping("/baseuser")
public class BaseUserController {

    @Resource
    private IBaseUserService is;


    //更新和插入

    @ApiOperation(value = "插入用户")
    @GetMapping("/saveorupde")
    public Message saveorupde(BaseUser baseUser){

        is.saveOrUpdat(baseUser);
        return MessageUtil.success("更新操作成功");
    }



    //查询
    @ApiOperation(value = "显示用户")
    @GetMapping("/show")
    public Message show(String username){
        List<BaseUser> list =is.query(username);
        return MessageUtil.success(list);
    }



    //删除操作
    @ApiOperation(value = "删除用户")
    @GetMapping("/delete")
    public Message delete(Long id){
        is.deleteById(id);
        return MessageUtil.success("删除成功");
    }


    //查询所有
    @ApiOperation(value = "查询所有用户")
    @GetMapping("/showAll")
    public Message showALl(){
       return MessageUtil.success(is.queryAll());

    }

}
